package com.rui.study.micro.userself.controller;

import com.rui.study.commons.model.BaseController;
import com.rui.study.commons.model.Result;
import com.rui.study.micro.userself.model.RegisterAccountDTO;
import com.rui.study.micro.userself.model.RegisterAccountGroup;
import com.rui.study.micro.userself.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class RegisterAccountController extends BaseController {

    @Autowired
    private AccountService accountService;

    /**
     * 1--注册账号，支持 邮箱/手机
     * @param registerAccountDTO
     * @param bindingResult
     * @return
     */
    @PutMapping("/v1/account")
    public Result registerAccount(@Validated(RegisterAccountGroup.class)
                                      @RequestBody RegisterAccountDTO registerAccountDTO,
                                  BindingResult bindingResult) {
        accountService.registerAccount(registerAccountDTO);
        return new Result();
    }
}
